package com.itaq.cheetah.serviceA.config.web;

import com.itaq.cheetah.serviceA.config.web.interceptor.AccessLogInterceptor;
import com.itaq.cheetah.serviceA.config.web.resolver.VefifySignArgumentResolver;
import com.itaq.cheetah.serviceA.dao.ISsoClientDetailMapper;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * @author cheetah
 * @date 2021/12/13
 */
@Configuration
@AllArgsConstructor
@Slf4j
public class WebConfig implements WebMvcConfigurer {

    private final ISsoClientDetailMapper iSsoClientDetailMapper;

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
        resolvers.add(new VefifySignArgumentResolver(iSsoClientDetailMapper));
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new AccessLogInterceptor());
    }
}
